// Windows/FileName.cpp

#include "StdAfx.h"

#include "FileName.h"
#include "Wildcard.h"


namespace Common
{
namespace FileSystem
{
namespace FileName
{

void NormalizeDirPathPrefix(CString &dirPath)
{
	if (dirPath.IsEmpty())
	{
		return;
	}
	if (dirPath.ReverseFind(kDirDelimiter) != dirPath.GetLength() - 1)
	{
		dirPath += kDirDelimiter;
	}
}

const wchar_t kExtensionDelimiter = L'.';

void SplitNameToPureNameAndExtension(const CString &fullName,
									 CString &pureName, CString &extensionDelimiter, CString &extension)
{
	int index = fullName.ReverseFind(kExtensionDelimiter);
	if (index < 0)
	{
		pureName = fullName;
		extensionDelimiter.Empty();
		extension.Empty();
	}
	else
	{
		pureName = fullName.Left(index);
		extensionDelimiter = kExtensionDelimiter;
		extension = fullName.Mid(index + 1);
	}
}

}
}
}